package com.ruoyi.system.domain.vo;

import com.fasterxml.jackson.annotation.JsonCreator;

public enum OperationType {
    OUTBOUND(0, "出库"),
    INBOUND(1, "进库");

    private final int code;
    private final String desc;

    OperationType(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    @JsonCreator
    public static OperationType fromCode(int code) {
        for (OperationType type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效的操作类型编码: " + code);
    }
}